package com.fosu.dao;

import com.fosu.domain.ProductAndCampus;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * @author zqa
 * @version 1.0
 * @date 2020/10/22 10:24
 */
@Mapper
@Repository
public interface ProductAndCampusDao {

    /**
     * 插入产品和校区之间的关系
     * @param productAndCampus 商品与校区关系类对象
     */
    @Results(id = "productAndCampusMap", value = {
            @Result(property = "campusId", column = "campus_id"),
            @Result(property = "productId", column = "product_id"),
    })
    @Insert("insert into product_campus(campus_id,product_id) values(#{campusId},#{productId})")
    void save(ProductAndCampus productAndCampus);

    /**
     * 删除所有与产品有关的校区
     * @param productId 商品id
     */
    @Delete("delete from product_campus where product_id=#{productId}")
    void clean(int productId);
}
